{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a58b900b",
   "metadata": {},
   "source": [
    "-------------------\n",
    "* week-09-列表\n",
    "* 课程：python\n",
    "* 记录人：成志鹏\n",
    "-------------------"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1773f489",
   "metadata": {},
   "source": [
    "# 本周学习目标\n",
    "> 1. 列表的方法\n",
    "> 2. while循环\n",
    "\n",
    "## 1.列表的方法\n",
    "> 1. 使用.tab键查看列表的方法\n",
    "> 2. 使用help(查看方法的使用规则)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3a1d83df",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'Marry', 'Jan']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"jack\",\"alex\",\"Marry\",\"Jan\"]\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "91e3ab68",
   "metadata": {},
   "source": [
    "## 1.1列表的增加"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a9572b28",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.append(\"Lihua\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "94930324",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d9d62aba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.append)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c4921fb1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "b9b1cd16",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.insert(2,\"Zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "300ef21c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'Zhichao', 'Zhichao', 'Zhichao', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ed28c48a",
   "metadata": {},
   "source": [
    "### 2. 列表的删除"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "96936e61",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "7a5fc43c",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.remove(\"Zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "5bb1963e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "93a10768",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "list.remove(x): x not in list",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [28]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mnames\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mremove\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mZhichao\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mValueError\u001b[0m: list.remove(x): x not in list"
     ]
    }
   ],
   "source": [
    "names.remove(\"Zhichao\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "808e2e56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e92e482b",
   "metadata": {},
   "source": [
    "* 正确的删除方法的流程\n",
    "> 1. 查询value是否在列表当中\n",
    "> 2 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "9a45c21f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"Wang\" in names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "ccbfee34",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "list.remove(x): x not in list",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[1;32mIn [40]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mnames\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mremove\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mWang\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mValueError\u001b[0m: list.remove(x): x not in list"
     ]
    }
   ],
   "source": [
    "names.remove(\"Wang\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "907595de",
   "metadata": {},
   "outputs": [],
   "source": [
    "if\"Wang\" in names:\n",
    "    names.remove(\"Wang\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "14b0c90a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['jack', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "007b5fb8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入要删除的内容：Lihua\n"
     ]
    },
    {
     "ename": "NameError",
     "evalue": "name 'name' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [43]\u001b[0m, in \u001b[0;36m<cell line: 2>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m user_input_name \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m请输入要删除的内容：\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m      2\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m user_input_name \u001b[38;5;129;01min\u001b[39;00m names:\n\u001b[1;32m----> 3\u001b[0m     \u001b[43mname\u001b[49m\u001b[38;5;241m.\u001b[39mremove(user_input_name)\n\u001b[0;32m      4\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m      5\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m您输入的结果不存在，删除无效\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
      "\u001b[1;31mNameError\u001b[0m: name 'name' is not defined"
     ]
    }
   ],
   "source": [
    "user_input_name = input(\"请输入要删除的内容：\")\n",
    "if user_input_name in names:\n",
    "    name.remove(user_input_name)\n",
    "else:\n",
    "    print(\"您输入的结果不存在，删除无效\")\n",
    "print(names)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "af84adfa",
   "metadata": {},
   "source": [
    "### 3.列表的修改"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "025c2ffb",
   "metadata": {},
   "outputs": [],
   "source": [
    "names[0] = \"Zhichao\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "763e6745",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Zhichao', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2e89ab30",
   "metadata": {},
   "source": [
    "## 4.列表的其他方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "e0e4c37c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Zhichao', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "de3b5bac",
   "metadata": {},
   "outputs": [],
   "source": [
    "names.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "57f2fbe3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "67b4fd21",
   "metadata": {},
   "outputs": [],
   "source": [
    "names= ['Zhichao', 'alex', 'Marry', 'Jan', 'Lihua']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "0fad7e04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Zhichao', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "eaaaf36c",
   "metadata": {},
   "outputs": [],
   "source": [
    "names_class1 = ['Zhichao', 'alex', 'Marry', 'Jan', 'Lihua']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "f529992c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Zhichao', 'alex', 'Marry', 'Jan', 'Lihua']"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names_class1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "641e8850",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function extend:\n",
      "\n",
      "extend(iterable, /) method of builtins.list instance\n",
      "    Extend list by appending elements from the iterable.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(names.extend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "00880886",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['李晓峰', '王丽', '刘明']"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names_class2 = [\"李晓峰\",\"王丽\",\"刘明\"]\n",
    "names_class2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "7fd2f514",
   "metadata": {},
   "outputs": [],
   "source": [
    "names_class1.extend(names_class2) #注意：使用列表的方法的列表进行扩展"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "c6bbfa04",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Zhichao',\n",
       " 'alex',\n",
       " 'Marry',\n",
       " 'Jan',\n",
       " 'Lihua',\n",
       " '李晓峰',\n",
       " '王丽',\n",
       " '刘明',\n",
       " '李晓峰',\n",
       " '王丽',\n",
       " '刘明']"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names_class1"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "09aeac32",
   "metadata": {},
   "source": [
    "* sort()排序\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "6f525384",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生 = [230,250,255,260,270]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "197e6bcf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sort:\n",
      "\n",
      "sort(*, key=None, reverse=False) method of builtins.list instance\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(立定跳远_男生.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "639611c4",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生.sort()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "0c4875f5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[230, 250, 255, 260, 270]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "立定跳远_男生"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "dc116184",
   "metadata": {},
   "outputs": [],
   "source": [
    "立定跳远_男生.sort(reverse=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "a44c59cc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[270, 260, 255, 250, 230]"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "立定跳远_男生"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "91937a0f",
   "metadata": {},
   "source": [
    "# 2.while循环\n",
    "\n",
    "* while True 是循环概念中非常重要的一种方式。它可以实现for循环的指定次数，也可以在特定条件下停止。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "2aa071de",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "你是风儿我是沙，缠缠绵绵到天涯。。。 0\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 1\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 2\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 3\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 4\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 5\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 6\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 7\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 8\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 9\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 10\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 11\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 12\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 13\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 14\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 15\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 16\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 17\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 18\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 19\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 20\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 21\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 22\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 23\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 24\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 25\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 26\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 27\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 28\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 29\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 30\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 31\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 32\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 33\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 34\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 35\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 36\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 37\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 38\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 39\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 40\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 41\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 42\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 43\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 44\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 45\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 46\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 47\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 48\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 49\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 50\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 51\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 52\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 53\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 54\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 55\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 56\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 57\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 58\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 59\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 60\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 61\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 62\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 63\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 64\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 65\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 66\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 67\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 68\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 69\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 70\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 71\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 72\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 73\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 74\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 75\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 76\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 77\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 78\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 79\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 80\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 81\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 82\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 83\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 84\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 85\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 86\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 87\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 88\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 89\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 90\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 91\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 92\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 93\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 94\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 95\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 96\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 97\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 98\n",
      "你是风儿我是沙，缠缠绵绵到天涯。。。 99\n"
     ]
    }
   ],
   "source": [
    "# 死循环\n",
    "\n",
    "count = 0\n",
    "while True:\n",
    "    print(\"你是风儿我是沙，缠缠绵绵到天涯。。。\",count)\n",
    "    count = count+1\n",
    "    if count ==100:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "e107a580",
   "metadata": {},
   "outputs": [
    {
     "ename": "IndentationError",
     "evalue": "expected an indented block (4068190780.py, line 8)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [75]\u001b[1;36m\u001b[0m\n\u001b[1;33m    guess_digit = int(input(\"猜一猜(0-100):\"))\u001b[0m\n\u001b[1;37m    ^\u001b[0m\n\u001b[1;31mIndentationError\u001b[0m\u001b[1;31m:\u001b[0m expected an indented block\n"
     ]
    }
   ],
   "source": [
    "## 小游戏： 猜数字，\n",
    "# 1. hide_card   : 0-100, 大了，小了\n",
    "# 2. guess_digit : 50\n",
    "count = 0\n",
    "hide_card = int(input(\"hide_card:\"))\n",
    "\n",
    "while True:\n",
    "guess_digit = int(input(\"猜一猜(0-100):\"))\n",
    "\n",
    "# 对比:\n",
    "if hide_card == guess_digit:\n",
    "    print(\"你超棒！！！\")\n",
    "    break\n",
    "elif hide_card < guess_digit:\n",
    "    \n",
    "else:\n",
    "    print(\"往大的猜！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c7f15a5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1dcede8e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "02048079",
   "metadata": {},
   "source": [
    "# 课后练习：\n",
    ">1.列表的切片和方法的使用\n",
    ">>1. 课本p67 练习\n",
    ">>2. 课本p81\n",
    ">2. p89:列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "51cd75f0",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
